---@class HeroIcon : GComponent
local HeroIcon = fgui.extension("ui://AtlasHero/Com_HeroIcon",GComponent)
function HeroIcon:ctor()
    self.heroIcon = self:GetChild("mask"):GetChild("icon")
    self.type = self:GetChild("type")
    self.textCost = self:GetChild("text_cost")
    self.textName = self:GetChild("text_name")
    self.ctrlSelect = self:GetController("select")
    self.heroId = 0
end
function HeroIcon:Dispose()
    self.heroIcon = nil
    self.type = nil
    self.textCost = nil
    self.textName = nil
end
function HeroIcon:SetSelected(isSelect)
    self.ctrlSelect.selectedIndex = isSelect and 1 or 0
end
---序列下标
function HeroIcon:SetIndex(index)
    self.index = index
end
function HeroIcon:SetHeroId(id)
    self.heroId = id

    if id == nil then return end
    self.cfg = DataTable.GetById("t_hero",self.heroId)
    self.showCfg = DataTable.GetById("t_heroresources",self.heroId)
    self:Refresh()
end
function HeroIcon:Refresh()
    self.heroIcon.url = IconUtil.GetHeroCardIconUrl(self.heroId)
    self.textCost.text = tostring(self.cfg.f_ConsumeEnergy)
    self.textName.text = self.cfg.f_HeroName
end
function HeroIcon:RegisterOnClick(callback,tb)
    self.clickCallback = callback
    self.clickCallbackTB = tb
    self.onClick:Clear()
    self.onClick:Add(self.ClickItem,self)
end
function HeroIcon:ClickItem()
    if self.clickCallback then
        self.clickCallback(self.clickCallbackTB,self)
    end
end
return HeroIcon